<?php

/**
* @copyright   (C) 2010 iJoomla, Inc. - All rights reserved.
* @license  GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html) 
* @author  iJoomla.com webmaster@ijoomla.com
* @url   http://www.ijoomla.com/licensing/
* the PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript  
* are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0 
* More info at http://www.ijoomla.com/licensing/
*/

defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.view');

class iJoomla_SurveysViewNewpage extends JView {
	
	function display($tpl = null){				
		JToolBarHelper::title(JText::_('COM_SURVEYS_SURVEY'));
		JToolBarHelper::save();
		JToolBarHelper::apply();
		JToolBarHelper::cancel();
		JToolBarHelper::divider();
		JToolBarHelper::help('com_surveys',true);
					
		$this->values = $this->get("PageValues");				
						
		parent::display($tpl);	
	}
	
	function getOrdering($ordering){
		$pages = $this->get("Pages");
		$return = "";
		$selected = "";
		
		if(count($pages) > 0){
			$return .= "<select name=\"ordering\">";			
			if($ordering == 0){
				$selected = ' selected="selected" ';
			}
			$return .= "<option value=\"0\" ".$selected.">0. ".JText::_("COM_SURVEYS_FIRST")."</option>";
			$selected = "";
			foreach($pages as $key=>$value){
				if($value["ordering"] == $ordering){
					$selected = ' selected="selected" ';
				}
				$return .= "<option value=\"".$value["ordering"]."\" ".$selected.">".$value["ordering"].". ".stripslashes($value["title"])."</option>";
				$selected = "";
			}
			if($ordering == "last"){
				$selected = ' selected="selected" ';
			}
			$return .= "<option value=\"last\" ".$selected.">".(count($pages)+1).". ".JText::_("COM_SURVEYS_LAST")."</option>";
			$return .= "</select>";
		}
		
		return $return;
	}
	
	function getSurveysList($default){
		$result = $this->get("AllSurveys");
		$return = '<select name="survey_id">';
		$selected = "";
		foreach($result as $key=>$value){
			$selected = "";
			if($value["id"] == $default){
				$selected = ' selected="selected" '; 
			}
			$return .= "<option value=\"".$value["id"]."\" ".$selected." >".$value["title"]."</option>";			
		}
		$return .= "</select>";
		return $return;
	}
}

?>
 